<template>
  <div id="OrdersTitle">
    <g-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules" @pop="setdata" ref="input"></g-details>
  </div>
</template>

<script>
import details from 'commons/Detail'
import baseMixin from "@/mixins/BaseMixin";

export default {
  props: {
    inputData: {
      type: Object,
    }
  },
  mixins: [baseMixin],
  name: "OrdersTitle",
  data() {
    return {
      addflag: true,
      rules: {
        storerkey: [
          { required: true, trigger: 'blur' },
        ]
      },
    }
  },
  computed: {
    inputConfig() {
      return [
        {
          type: "input",
          label: this.$t('in.adjustmentkey'),
          props: "adjustmentkey",
          disabled: true
        },
        {
          type: "table",
          label: this.$t('config.shipper'),
          props: "storerkey",
          tableConfig: [
            {
              label: this.$t('config.shipper'),
              prop: "storerkey",
              input: "input",
            },
            {
              label: this.$t('config.company'),
              prop: "company",
              input: "input",
            },
            {
              label: this.$t('config.city'),
              prop: "city",
              input: "input",
            },
            {
              label: this.$t('config.provice'),
              prop: "state",
              input: "input",
            },
            {
              label: this.$t('config.postcode'),
              prop: "zip",
              input: "input",
            },
            {
              label: this.$t('config.contact'),
              prop: "contact",
              input: "input",
            },
            {
              label: this.$t('config.phone'),
              prop: "phone",
              input: "input",
            }
          ],
          url: `/queryStorer/1/?/${this.$store.state.wms}`,
          disabled: this.addflag,
          filterKey:"storerkey",
          break:true
        },
        {
          type: "date",
          label: this.$t('app.addDate'),
          props: "adddate",
          disabled: true
        },
        {
          type: "input",
          label: this.$t('app.addName'),
          props: "addwho",
          disabled: true
        },
        // {
        //   type: "date",
        //   label: this.$t('in.effectivedate'),
        //   props: "effectivedate",
        //   disabled: true
        // },
        {
          type: "input",
          label: "Reference Number",
          props: "referencenumber",
          disabled: true,
          break:true
        },
        // {
        //   type: "checkbox",
        //   label: this.$t('ex.rtxudf10'),
        //   props: "rtxudf10",
        //   disabled: true
        // },
        {
          type: "textarea",
          label: this.$t('ex.notes'),
          props: "notes",
          disabled: true
        }
      ]

    }
  },
  methods: {
    setdata(data, close, listId) {
      this.inputData.storerkey = data.storerkey;
      close(false);
    }
  },
  mounted() {
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      if (!data.newFlag) {
        this.addflag = true;
      } else {
        this.addflag = false;
      }
    } else if (!this.$store.state.newFlag) {
      this.addflag = true;
    } else {
      this.addflag = false;
    }
  },
  watch: {},
  components: {
    'v-details': details
  }
}
</script>

<style scoped>

</style>
